import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const UserIdKey = 'Admin-UserId'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  let inFifteenMinutes = new Date(new Date().getTime() + 60 * 60 * 1000);
  return Cookies.set(TokenKey, token, {expires: inFifteenMinutes})
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserId() {
  return Cookies.get(UserIdKey)
}

export function setUserId(userId) {
  let inFifteenMinutes = new Date(new Date().getTime() + 60 * 60 * 1000);
  return Cookies.set(UserIdKey, userId, {expires: inFifteenMinutes})
}

export function removeUserId() {
  return Cookies.remove(UserIdKey)
}
